<include file="Common:header"/>
<style>
	body {
    	background-color: #F1F1F1;
	}
	.content .phoneinfo form table tr .register{
		background-color: #3cd09a;
		color:#fff;
		font-size: 14px;
		border:none;
	}
	.reg_dsc{
		margin-top:10px;
		color:#E86767;
		text-align: center;
		font-size: 15px;
	}
</style>
<body>
	<div class="header">
		用户注册
		<a href="javascript:history.back();" class="back">
			<img src="__PUBLIC__/img/back.png"><span class="back_cs">返回</span>
		</a>
	</div>
	<div class="content" style="margin-top:0;">
		<if condition="$uid">
		<div class="ad_infocc23">				
			<p class="ccp23">介绍人：<{$higher_info['username']}></p>
			<div class="erweimakk">
			<img src="<{$qrcode_url}>" alt="">
			</div>
			<p>微信号：<{$higher_info['weixin']}></p>
		</div>
		</if>
		<div class="phoneinfo">
			<form method="POST" id="myform">
				<table>
					<tr>
						<!-- <td class="tdname">手机号码：</td> -->
						<td><input type="tel" pattern="\d*" name="mobile" placeholder="手机号仅作账号 (不展示)"></td>
					</tr>
					<tr>
						<!-- <td class="tdname">密码：</td> -->
						<td><input type="password" name="password" placeholder="请输入您的密码 (6-16位)"></td>
					</tr>
					<tr>
						<!-- <td class="tdname">昵称：</td> -->
						<td><input type="text" name="username" placeholder="请输入您的昵称"></td>
					</tr>
					<tr>
						<!-- <td class="tdname">微信号：</td> -->
						<td><input type="text" name="weixin" placeholder="请输入您的微信号"></td>
					</tr>
					<tr>
						<td><input type="button" value="申&nbsp;请&nbsp;注&nbsp;册" class="register" onclick="register(this)"></td>
					</tr>
				</table>
			</form>
			<div class="clear"></div>			
		</div>
		<div class="reg_dsc">
			注册说明: 手机号码是你唯一的身份标识
		</div>
	</div>
</body>
</html>
<script src="__PUBLIC__/js/layer.m/layer.m.js"></script>
<script>
function register(obj){
	var uid = '<{:I('uid')}>';
	var mobile = $('input[name="mobile"]').val();
	var password = $('input[name="password"]').val();
	var username = $('input[name="username"]').val();
	var weixin = $('input[name="weixin"]').val();
	var allow = true;	// 允许提交
	if($(obj).attr('readonly')){
		return false;
	}
	$(obj).attr('readonly','readonly');

	if ($.trim(mobile) == '')
	{
		layer.open({
			title: [
				'提示',
			],
			content: '手机号码不能为空'
		});
		$(obj).removeAttr('readonly');
		return false;
	}

	if ($.trim(password) == '')
	{
		layer.open({
			title: [
				'提示',
			],
			content: '密码不能为空'
		});
		$(obj).removeAttr('readonly');
		return false;
	}

	if ($.trim(username) == '')
	{
		layer.open({
			title: [
				'提示',
			],
			content: '昵称不能为空'
		});
		$(obj).removeAttr('readonly');
		return false;
	}

	if ($.trim(weixin) == '')
	{
		layer.open({
			title: [
				'提示',
			],
			content: '微信号不能为空'
		});
		$(obj).removeAttr('readonly');
		return false;
	}


	var data = {
		'uid':uid,
		'mobile':mobile,
		'password':password,
		'username':username,
		'weixin':weixin,
	};

	$.post('<{:U('Home/Login/register')}>',data,function(index){
		if (index.error == 1){
			layer.open({
				title: [
					'提示',
				],
				content: index.errmsg
			});
			$(obj).removeAttr('readonly');
		}else{
			layer.open({
				content: index.errmsg,
				time: 2
			});
			window.location.href = "<{:U('Home/Index/index')}>";
		}
	},'json');
}
</script> 